package jcu.ict.profaid;

import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;

@SuppressLint("NewApi")
public class form_add_subject extends Activity{
	@SuppressLint("NewApi")
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.form_add_subject);

		ActionBar actionBar = getActionBar();
	    actionBar.setDisplayHomeAsUpEnabled(true);

	    String[] items = { "SP51","SP52","SP53"};

        Spinner spin = (Spinner) findViewById(R.id.spnSpcode);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_spinner_item,items);
        spin.setAdapter(adapter);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		new MenuInflater(this).inflate(R.menu.mysubject, menu);

		EditText add = null;

		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			View v = menu.findItem(R.id.createsubject).getActionView();

			if (v != null) {
			add = (EditText) v.findViewById(R.id.createsubject);
			}
		}

		if (add != null) {
			//add.setOnEditorActionListener(onSearch);
		}

		return (super.onCreateOptionsMenu(menu));
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
	    switch (item.getItemId()) {
	        case android.R.id.home:
	            // app icon in action bar clicked; go home
	            Intent intent = new Intent(this, form_my_subject.class);
	            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	            startActivity(intent);
	            return true;
	        default:
	            return super.onOptionsItemSelected(item);
	    }
	}
	public class form_add_subject extends Activity{
		@SuppressLint("NewApi")
		public void onCreate(Bundle savedInstanceState) {
}
		SQLiteDatabase db = openOrCreateDatabase("MyDB", MODE_PRIVATE, null);
		db.execSQL("CREATE TABLE IF NOT EXISTS Newsubject (create subject VARCHAR, serialno. NUMBER, SEMESTER VARCHAR, TIME NUMBER,Totalstudents NUMBER);");
		db.execSQL("INSERT INTO Newsubject VALUES('Algorithm', 1, 'SP51', 00, 30);");
		db.execSQL("INSERT INTO Newsubject VALUES('HCI', 2, 'SP51', 01, 30);");
		db.execSQL("INSERT INTO Newsubject VALUES('Esecurity', 3, 'SP51', 02, 45);");
		db.execSQL("INSERT INTO Newsubject VALUES('Oracle', 4, 'SP51', 03, 50);");
		db.execSQL("INSERT INTO Newsubject VALUES('Algorithm', 5, 'SP51', 04, 65);");

		cursor c=db.rawQuery("select * from Newsubject", null)
		c.moveToFirst();

		db.close();
}

